// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.MachineLearning;

public sealed partial class UpdateTrainedModelDeploymentRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>Starts a trained model deployment, which allocates the model to every machine learning node.</para>
/// </summary>
public sealed partial class UpdateTrainedModelDeploymentRequest : PlainRequest<UpdateTrainedModelDeploymentRequestParameters>
{
	public UpdateTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id modelId) : base(r => r.Required("model_id", modelId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateTrainedModelDeployment;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.update_trained_model_deployment";

	/// <summary>
	/// <para>The number of model allocations on each node where the model is deployed.<br/>All allocations on a node share the same copy of the model in memory but use<br/>a separate set of threads to evaluate the model.<br/>Increasing this value generally increases the throughput.<br/>If this setting is greater than the number of hardware threads<br/>it will automatically be changed to a value less than the number of hardware threads.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("number_of_allocations")]
	public int? NumberOfAllocations { get; set; }
}

/// <summary>
/// <para>Starts a trained model deployment, which allocates the model to every machine learning node.</para>
/// </summary>
public sealed partial class UpdateTrainedModelDeploymentRequestDescriptor : RequestDescriptor<UpdateTrainedModelDeploymentRequestDescriptor, UpdateTrainedModelDeploymentRequestParameters>
{
	internal UpdateTrainedModelDeploymentRequestDescriptor(Action<UpdateTrainedModelDeploymentRequestDescriptor> configure) => configure.Invoke(this);

	public UpdateTrainedModelDeploymentRequestDescriptor(Elastic.Clients.Elasticsearch.Id modelId) : base(r => r.Required("model_id", modelId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateTrainedModelDeployment;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.update_trained_model_deployment";

	public UpdateTrainedModelDeploymentRequestDescriptor ModelId(Elastic.Clients.Elasticsearch.Id modelId)
	{
		RouteValues.Required("model_id", modelId);
		return Self;
	}

	private int? NumberOfAllocationsValue { get; set; }

	/// <summary>
	/// <para>The number of model allocations on each node where the model is deployed.<br/>All allocations on a node share the same copy of the model in memory but use<br/>a separate set of threads to evaluate the model.<br/>Increasing this value generally increases the throughput.<br/>If this setting is greater than the number of hardware threads<br/>it will automatically be changed to a value less than the number of hardware threads.</para>
	/// </summary>
	public UpdateTrainedModelDeploymentRequestDescriptor NumberOfAllocations(int? numberOfAllocations)
	{
		NumberOfAllocationsValue = numberOfAllocations;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (NumberOfAllocationsValue.HasValue)
		{
			writer.WritePropertyName("number_of_allocations");
			writer.WriteNumberValue(NumberOfAllocationsValue.Value);
		}

		writer.WriteEndObject();
	}
}